from sqlalchemy import Column, Integer, String, SmallInteger, Boolean
from mooc.db.database import Base



class IMSModulesBindings(Base):
    __tablename__ = 'ims_modules_bindings'

    eid = Column(Integer, primary_key=True)
    module = Column(String(100), nullable=False)
    entry = Column(String(30), nullable=False)
    call = Column(String(50), nullable=False)
    title = Column(String(50), nullable=False)
    do = Column(String(200), nullable=False)
    state = Column(String(200), nullable=False)
    direct = Column(Integer, nullable=False)
    url = Column(String(100), nullable=False)
    icon = Column(String(50), nullable=False)
    displayorder = Column(SmallInteger, nullable=False)
    multilevel = Column(Boolean, nullable=False)
    parent = Column(String(50), nullable=False)


class IMSModulesCloud(Base):
    __tablename__ = 'ims_modules_cloud'

    id = Column(Integer, primary_key=True)
    name = Column(String(100), nullable=False)
    application_type = Column(SmallInteger, nullable=False)
    title = Column(String(100), nullable=False)
    title_initial = Column(String(1), nullable=False)
    logo = Column(String(100), nullable=False)
    version = Column(String(10), nullable=False)
    install_status = Column(SmallInteger, nullable=False)
    account_support = Column(SmallInteger, nullable=False)
    wxapp_support = Column(SmallInteger, nullable=False)
    webapp_support = Column(SmallInteger, nullable=False)
    phoneapp_support = Column(SmallInteger, nullable=False)
    welcome_support = Column(SmallInteger, nullable=False)
    main_module_name = Column(String(50), nullable=False)
    main_module_logo = Column(String(100), nullable=False)
    has_new_version = Column(Boolean, nullable=False)
    has_new_branch = Column(Boolean, nullable=False)
    is_ban = Column(SmallInteger, nullable=False)
    lastupdatetime = Column(Integer, nullable=False)
    xzapp_support = Column(Boolean, nullable=False)
    cloud_id = Column(Integer, nullable=False)
    aliapp_support = Column(Boolean, nullable=False)
    baiduapp_support = Column(Boolean, nullable=False)
    toutiaoapp_support = Column(Boolean, nullable=False)
    buytime = Column(Integer, nullable=False)
    module_status = Column(Boolean, nullable=False)


class Modules(Base):
    __tablename__ = 'ims_modules'

    mid = Column(Integer, primary_key=True, index=True, nullable=False)
    name = Column(String(100), nullable=False)
    application_type = Column(SmallInteger, nullable=False)
    type = Column(String(20), nullable=False)
    title = Column(String(100), nullable=False)
    version = Column(String(15), nullable=False)
    ability = Column(String(500), nullable=False)
    description = Column(String(1000), nullable=False)
    author = Column(String(50), nullable=False)
    url = Column(String(255), nullable=False)
    settings = Column(SmallInteger, nullable=False)
    subscribes = Column(String(500), nullable=False)
    handles = Column(String(500), nullable=False)
    isrulefields = Column(SmallInteger, nullable=False)
    issystem = Column(SmallInteger, nullable=False)
    target = Column(Integer, nullable=False)
    iscard = Column(SmallInteger, nullable=False)
    permissions = Column(String(5000), nullable=False)
    title_initial = Column(String(1), nullable=False)
    wxapp_support = Column(SmallInteger, nullable=False)
    welcome_support = Column(SmallInteger, nullable=False)
    oauth_type = Column(SmallInteger, nullable=False)
    webapp_support = Column(SmallInteger, nullable=False)
    phoneapp_support = Column(SmallInteger, nullable=False)
    account_support = Column(SmallInteger, nullable=False)
    xzapp_support = Column(SmallInteger, nullable=False)
    aliapp_support = Column(SmallInteger, nullable=False)
    logo = Column(String(250), nullable=False)
    baiduapp_support = Column(SmallInteger, nullable=False)
    toutiaoapp_support = Column(SmallInteger, nullable=False)
    from_ = Column(String(10), nullable=False)
    cloud_record = Column(SmallInteger, nullable=False)
    sections = Column(Integer, nullable=False)


class IMSModulesIgnore(Base):
    __tablename__ = 'ims_modules_ignore'

    id = Column(Integer, primary_key=True)
    name = Column(String(100), nullable=False)
    version = Column(String(15), nullable=False)


class IMSModulesPlugin(Base):
    __tablename__ = 'ims_modules_plugin'

    id = Column(Integer, primary_key=True)
    name = Column(String(100), nullable=True)
    main_module = Column(String(100), nullable=True)


class IMSModulesPluginRank(Base):
    __tablename__ = 'ims_modules_plugin_rank'

    id = Column(Integer, primary_key=True)
    uniacid = Column(Integer, nullable=False)
    uid = Column(Integer, nullable=False)
    rank = Column(Integer, nullable=False)
    plugin_name = Column(String(200), nullable=False)
    main_module_name = Column(String(200), nullable=False)


class IMSModulesRank(Base):
    __tablename__ = 'ims_modules_rank'

    id = Column(Integer, primary_key=True)
    module_name = Column(String(100), nullable=False)
    uid = Column(Integer, nullable=False)
    rank = Column(Integer, nullable=False)
    uniacid = Column(Integer, nullable=False)

class IMSModulesRecycle(Base):
    __tablename__ = 'ims_modules_recycle'

    id = Column(Integer, primary_key=True)
    name = Column(String(255), nullable=False)
    type = Column(SmallInteger, nullable=False)
    account_support = Column(Boolean, nullable=False)
    wxapp_support = Column(Boolean, nullable=False)
    welcome_support = Column(Boolean, nullable=False)
    webapp_support = Column(Boolean, nullable=False)
    phoneapp_support = Column(Boolean, nullable=False)
    xzapp_support = Column(Boolean, nullable=False)
    aliapp_support = Column(Boolean, nullable=False)
    baiduapp_support = Column(Boolean, nullable=False)
    toutiaoapp_support = Column(Boolean, nullable=False)

